#ifndef TextMarker_First
#define TextMarker_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Rectangle.h"
#include "Token.h"
#include "Mark.h"

class VObject;
class Data;
class Clipper;
class Command;

//---- VisualMark --------------------------------------------------------------
//     VisualMarks are objects with a visual representation. They
//     can be inserted in a text and behave like characters.

class VisualMark: public Mark {
public:
	MetaDef(VisualMark);

	VisualMark();
	VisualMark(const char *tag);
	~VisualMark();
	
	virtual void CalcExtent();
	virtual Point GetExtent();
	virtual int Base();

	virtual void Draw(const Point &at, const Rectangle &clip,
					const Rectangle &line, bool border);
	virtual void SendDown(int, int, void*);
	virtual void SetContainer(VObject*);

	virtual bool WantsInput(Point lp);
	virtual Command *Input(Point lp, Token &t, Clipper *cl);

	virtual VObject *GetVObject(); // compatibility

	void SetTag(const char *t);     // client data
	const char *GetTag();

protected:
	char *tag;
};

inline const char *VisualMark::GetTag()
	{ return tag; }

//---- VObjectMark -------------------------------------------------------------
//     a mark managing a VObject

class VObjectMark: public VisualMark {
public:
	MetaDef(VObjectMark);

	VObjectMark(VObject *vo= 0, const Point &sizeHint= gPoint_1);
	VObjectMark(VObject *vo, const char *tag, const Point &sizeHint= gPoint_1);
	VObjectMark(const char *tag, const Point &sizeHint= gPoint_1);
	~VObjectMark();

	void InitNew();
	virtual VObject *GetVObject();

	void CalcExtent();
	Point GetExtent();
	int Base();
	void SetContainer(VObject*);
	void Draw(const Point &at, const Rectangle &clip, const Rectangle &line, bool border);
	void SendDown(int, int, void*);
	bool WantsInput(Point p);
	virtual Command *Input(Point lp, Token &t, Clipper *cl);

	void FreeAll();
	OStream& PrintOn(OStream&);
	IStream& ReadFrom(IStream&);
	void CollectParts(Collection *col);

protected:
	VObject *vop;
	Point sizeHint;
};

//---- ReferenceMark ------------------------------------------------------
//     a Reference to a graphical object stored in a Data
//     the image is loaded on demand

class ReferenceMark: public VObjectMark {
public:
	MetaDef(ReferenceMark);

	ReferenceMark(const char *filename, const Point &sizeHint= gPoint_1);
	ReferenceMark(const char *filename, const char *tag);
	ReferenceMark(Data *data, const Point &sizeHint= gPoint_1);
	~ReferenceMark();

	VObject *GetVObject();
	const char *FileName();

	// vobject protocol
	void SetContainer(VObject*);

	// object protocol
	OStream& PrintOn(OStream&);
	IStream& ReadFrom(IStream&);

protected:
	void VerifyData();

protected:
	VObject *container;
	Data *data;
};

#endif

